import req from '@/utils/request';
import * as URL from '@/constants/api';

export function follow(id) {
  return req({
    method: 'post',
    url: URL.FOLLOW,
    data: {
      target: id,
    },
  })
  // 处理成功
    .then(res => res.data.message)
    .catch(() => Promise.reject(err.response.data.message));
}

export function login(params) {
  return req({
    method: 'post',
    url: URL.LOGIN,
    data: params,
  })
    .then(res => {
      localStorage.setItem('TOKEN', `Bearer ${ res.data.data.token }`);
      return res.data.message
    })
    .catch(() => Promise.reject(err.response.data.message));
}
